module Validations
  def validates_positiveness_of(*attr_names)
    configuration = { :message => "should be positive", :on => :save }
    configuration.update(attr_names.extract_options!)
    
    validates_each(attr_names, configuration) do |record, attr, value|
      if !value.nil? and value < 0
        record.errors.add(attr, configuration[:message])
      end
    end
  end
end

ActiveRecord::Base.extend Validations
